<template>
  <MrCustom bg-color="bg-gradual-blue " is-back>
    <template #backText>
      返回
    </template>
  </MrCustom>
  <view v-if="inquiryInfo" class="bg-white">
    <InquiryItem :inquiry-item="inquiryInfo"></InquiryItem>
    <view class="bg-white margin-bottom-lg">
      <view class="cu-bar">
        <view class="text-black text-xxl padding-lr-sm">
          全部解答
        </view>
      </view>
      <z-paging ref="pagingRef" @query="queryList" v-model="list" use-page-scroll>
        <CommentList :list="list" can-reply></CommentList>
      </z-paging>
    </view>
  </view>
</template>

<script setup lang="ts">
import {onLoad} from "@dcloudio/uni-app";
import {ref} from "vue";
import UniCard from "@/uni_modules/uni-card/components/uni-card/uni-card.vue";
import InquiryItem from "@/components/common/item/InquiryItem.vue";

import {imagePathPrefix} from '/settings'
import api from "@/api";
import CommentList from "@/components/common/list/CommentList.vue";
import MrCustom from "@/components/common/MrCustom.vue";
const prefix =imagePathPrefix

const inquiryInfo = ref()
const pagingRef=ref()
const list =ref()
onLoad((option) => {
  inquiryInfo.value = JSON.parse(decodeURIComponent(option.inquiryInfo))
})

/**
 * 评论
 */
const queryList = (pageNo: any, pageSize: any) => {
  api.comment.commentList({
    targetId: inquiryInfo.value.id,
    targetType: 5,
    pageNo: pageNo,
    pageSize: pageSize
  }).then(res => {
    if (res && res.data.code === 0) {
      let tmp = res.data.data.records
      pagingRef.value.complete(tmp);
    }
  })
}



const viewImage = (e: any) => {
  let tmp = JSON.parse(JSON.stringify(inquiryInfo.value.images,))
  Object.keys(tmp).forEach(key => {
    tmp[key] =prefix+ tmp[key]
  })
  uni.previewImage({
    urls: tmp,
    current: e.currentTarget.dataset.url
  });
}


</script>

<style scoped>

</style>